using System;

namespace RideMe.AddIns.Events
{
    /// <summary>
    /// This contains events related to the project file being worked on
    /// </summary>
    public class ProjectEventSource
    {
        #region Events

        public event EventHandler<FileEventArgs> ProjectOpened;
        public event EventHandler<FileEventArgs> ProjectClosed;
        public event EventHandler<FileEventArgs> ProjectCreated;
        public event EventHandler<FileEventArgs> FileOpened;
        public event EventHandler<FileEventArgs> FileClosed;
        public event EventHandler<FileEventArgs> FileDeleted;
        public event EventHandler<RenamedFileEventArgs> FileRenamed;
        public event EventHandler<FileEventArgs> FileSelected;

        #endregion

        #region Event Methods

        /// <summary>
        /// This should be called when a project is opened, to notify all subscribers that this event has taken place
        /// </summary>
        /// <param name="e"></param>
        public void OnProjectOpened(FileEventArgs e)
        {
            if (ProjectOpened != null)
                ProjectOpened(this, e);
        }

        /// <summary>
        /// This should be called when a project is closed, to notify all subscribers that this event has taken place
        /// </summary>
        /// <param name="e"></param>
        public void OnProjectClosed(FileEventArgs e)
        {
            if (ProjectClosed != null)
                ProjectClosed(this, e);
        }

        /// <summary>
        /// This should be called when a project is created, to notify all subscribers that this event has taken place
        /// </summary>
        /// <param name="e"></param>
        public void OnProjectCreated(FileEventArgs e)
        {
            if (ProjectCreated != null)
                ProjectCreated(this, e);
        }

        /// <summary>
        /// This should be called when a file is opened, to notify all subscribers that this event has taken place
        /// </summary>
        /// <param name="e"></param>
        public void OnFileOpened(FileEventArgs e)
        {
            if (FileOpened != null)
                FileOpened(this, e);
        }

        /// <summary>
        /// This should be called when a file is closed, to notify all subscribers that this event has taken place
        /// </summary>
        /// <param name="e"></param>
        public void OnFileClosed(FileEventArgs e)
        {
            if (FileClosed != null)
                FileClosed(this, e);
        }

        /// <summary>
        /// This should be called when a file is deleted, to notify all subscribers that this event has taken place
        /// </summary>
        /// <param name="e"></param>
        public void OnFileDeleted(FileEventArgs e)
        {
            if (FileDeleted != null)
                FileDeleted(this, e);
        }

        /// <summary>
        /// This should be called when a file is renamed, to notify all subscribers that this event has taken place
        /// </summary>
        /// <param name="e"></param>
        public void OnFileRenamed(RenamedFileEventArgs e)
        {
            if (FileRenamed != null)
                FileRenamed(this, e);
        }

        /// <summary>
        /// This should be called when a file is selected, to notify all subscribers that this event has taken place
        /// </summary>
        /// <param name="e"></param>
        public void OnFileSelected(FileEventArgs e)
        {
            if (FileSelected != null)
                FileSelected(this, e);
        }

        #endregion

        #region Event Args

        /// <summary>
        /// These event args are raised with an event pertaining to a single file
        /// </summary>
        public class FileEventArgs : EventArgs
        {
            #region Constructor

            /// <summary>
            /// This builds the event args based on the path
            /// </summary>
            /// <param name="path"></param>
            public FileEventArgs(string path)
                : base()
            {
                _path = path;
            }

            #endregion

            #region Properties

            /// <summary>
            /// This gets the path represented by the file for which the event args are raised
            /// </summary>
            public string Path
            {
                get { return _path; }
            }

            #endregion

            #region Private Variables

            private string _path;

            #endregion
        }

        /// <summary>
        /// These event args are raised with an event pertaining to the renaming of a file from one path to another
        /// </summary>
        public class RenamedFileEventArgs : EventArgs
        {
            #region Constructor

            /// <summary>
            /// This constructor builds the event args based off of the two input paths
            /// </summary>
            /// <param name="oldPath"></param>
            /// <param name="newPath"></param>
            public RenamedFileEventArgs(string oldPath, string newPath)
                : base()
            {
                _oldPath = oldPath;
                _newPath = newPath;
            }

            #endregion

            #region Properties

            /// <summary>
            /// This returns the old path of the renamed file
            /// </summary>
            public string OldPath
            {
                get { return _oldPath; }
            }

            /// <summary>
            /// This returns the new path of the renamed file
            /// </summary>
            public string NewPath
            {
                get { return _newPath; }
            }

            #endregion

            #region Private Variables

            private string _oldPath;
            private string _newPath;

            #endregion
        }

        #endregion
    }
}
